<template>
  <el-dialog
    title="提现审核"
    :visible.sync="visible"
    :before-close="handleClose"
    width="30%"
  >
    <el-form ref="form" :model="form">
      <el-form-item label="是否同意提现">
        <el-radio-group v-model="form.status">
          <el-radio :label="1">同意提现</el-radio>
          <el-radio :label="2">不同意提现</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        label="反馈备注"
        prop="remarks"
        :rules="{ required: true, message: '请输入反馈备注', trigger: 'blur' }"
      >
        <el-input
          v-model="form.remarks"
          type="textarea"
          :autosize="{ minRows: 2, maxRows: 4 }"
          placeholder="请输入内容"
        >
        </el-input>
      </el-form-item>
    </el-form>

    <span slot="footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="handleSumbit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { CASHEXAMINE } from "../../service";

export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    val: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      form: {
        status: 1,
        remarks: ""
      }
    };
  },
  methods: {
    handleClose() {
      this.$emit("outDialog");
    },
    changes(page) {
      this.pages = page;
      this.getList();
    },
    async handleSumbit() {
      await this.$refs["form"].validate(valid => {
        if (valid) {
          CASHEXAMINE({
            cash_id: this.val.cash_id,
            status: this.form.status,
            remarks: this.form.remarks
          }).then(({ code, msg }) => {
            if (code === 200) {
              this.$emit("outDialog");
            }
            this.$message({
              message: msg,
              type: code === 200 ? "success" : "error"
            });
          });
        } else {
          return false;
        }
      });
    }
  }
};
</script>
